// 禁言
const banChatMixin = {
	data(){
		return{
			isAllow: true,
			//禁言按钮样式
			button:{
				type: 'warn',
				text: '全体禁言',
				disabled: false
			}
		}
	},
	watch: {
		isAllow(e){
			this.button = {
				type: e?'warn':'primary',
				text: e?'全体禁言':'取消禁言',
				disabled: false
			}
		}
	},
	computed: {
		// 禁言按钮样式
		getStatus:function(){
			return function(type){
				let theme = this.theme;
				let typeEnum = {
					'warn': theme.danger,
					'primary': theme.success,
					'default': theme.info
				}
				return typeEnum[type];
			}
		},
	},
	methods: {
		// 拉取禁言信息
		getAllowSpeach(data){
			this.isAllow = data.isAllow;
		},
		//禁言、取消禁言
		banChat(){
			let classId = this.livePushInfo.channelClassId
			let type = this.button.type;
			this.socket.sendSocketMessage('0005', {
				id: this.id,
				classId: classId,
				isAllow: !this.isAllow
			}).catch(err=>{
				this.btnErr();
			})
		},
		btnErr(){
			this.button.type = 'default'
			this.button.disabled = true
		}
	}
}

export default banChatMixin;